//////////////////////////////////////////////////////
///载入管理器
//////////////////////////////////////////////////////
class LoadManager{
	static var lastLevelIndex:int;
	static var www:WWW;
	static var bundle:AssetBundle;

	/**
		载入场景
		@param url
	*/
	static function LoadLevel(url:String,onOk:Function){
		if(url.Length == 0){
			Debug.Log("url?"+url);
			return false;
		}
		www = WWW.LoadFromCacheOrDownload(url,0);
		if(www.error != null){
			Debug.Log("关卡下载失败:"+www.error);
			return false;
		}
		var index:int = url.LastIndexOf("/")+1;
		var levelName:String = url.Substring(index);
			levelName = levelName.Substring(0,levelName.IndexOf("."));
		//构建场景
		bundle = www.assetBundle;
		if(onOk != null){
			onOk(levelName);
		}else{
			lastLevelIndex = Application.loadedLevel;
			Application.LoadLevel(levelName);
		}
		return null;
	}

}